using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PACKETPARSERMAX20.CORE
{
	public class game_weather : MangosBase
	{
		public System.UInt32? zone;
		public System.Byte? spring_rain_chance;
		public System.Byte? spring_snow_chance;
		public System.Byte? spring_storm_chance;
		public System.Byte? summer_rain_chance;
		public System.Byte? summer_snow_chance;
		public System.Byte? summer_storm_chance;
		public System.Byte? fall_rain_chance;
		public System.Byte? fall_snow_chance;
		public System.Byte? fall_storm_chance;
		public System.Byte? winter_rain_chance;
		public System.Byte? winter_snow_chance;
		public System.Byte? winter_storm_chance;




		public override string GetInsertCommand()
		{
			return string.Format("INSERT IGNORE INTO `game_weather` (`zone`, `spring_rain_chance`, `spring_snow_chance`, `spring_storm_chance`, `summer_rain_chance`, `summer_snow_chance`, `summer_storm_chance`, `fall_rain_chance`, `fall_snow_chance`, `fall_storm_chance`, `winter_rain_chance`, `winter_snow_chance`, `winter_storm_chance`) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}');", zone.GetValueOrDefault(), spring_rain_chance.GetValueOrDefault(), spring_snow_chance.GetValueOrDefault(), spring_storm_chance.GetValueOrDefault(), summer_rain_chance.GetValueOrDefault(), summer_snow_chance.GetValueOrDefault(), summer_storm_chance.GetValueOrDefault(), fall_rain_chance.GetValueOrDefault(), fall_snow_chance.GetValueOrDefault(), fall_storm_chance.GetValueOrDefault(), winter_rain_chance.GetValueOrDefault(), winter_snow_chance.GetValueOrDefault(), winter_storm_chance.GetValueOrDefault());
		}


		public override string GetUpdateCommand()
		{
            StringBuilder sb = new StringBuilder();
						sb.Append("UPDATE `game_weather` SET ");
			if(spring_rain_chance != null)
			{
				sb.AppendLine("`spring_rain_chance`='" + spring_rain_chance.Value.ToString() + "'");
			}
			if(spring_snow_chance != null)
			{
				sb.AppendLine("`spring_snow_chance`='" + spring_snow_chance.Value.ToString() + "'");
			}
			if(spring_storm_chance != null)
			{
				sb.AppendLine("`spring_storm_chance`='" + spring_storm_chance.Value.ToString() + "'");
			}
			if(summer_rain_chance != null)
			{
				sb.AppendLine("`summer_rain_chance`='" + summer_rain_chance.Value.ToString() + "'");
			}
			if(summer_snow_chance != null)
			{
				sb.AppendLine("`summer_snow_chance`='" + summer_snow_chance.Value.ToString() + "'");
			}
			if(summer_storm_chance != null)
			{
				sb.AppendLine("`summer_storm_chance`='" + summer_storm_chance.Value.ToString() + "'");
			}
			if(fall_rain_chance != null)
			{
				sb.AppendLine("`fall_rain_chance`='" + fall_rain_chance.Value.ToString() + "'");
			}
			if(fall_snow_chance != null)
			{
				sb.AppendLine("`fall_snow_chance`='" + fall_snow_chance.Value.ToString() + "'");
			}
			if(fall_storm_chance != null)
			{
				sb.AppendLine("`fall_storm_chance`='" + fall_storm_chance.Value.ToString() + "'");
			}
			if(winter_rain_chance != null)
			{
				sb.AppendLine("`winter_rain_chance`='" + winter_rain_chance.Value.ToString() + "'");
			}
			if(winter_snow_chance != null)
			{
				sb.AppendLine("`winter_snow_chance`='" + winter_snow_chance.Value.ToString() + "'");
			}
			if(winter_storm_chance != null)
			{
				sb.AppendLine("`winter_storm_chance`='" + winter_storm_chance.Value.ToString() + "'");
			}
				sb = sb.Replace("\r\n", ", ");
				sb.Append(" WHERE `zone`='" + zone.Value.ToString() + "';");
				sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
		}


	}
}
